main: Print error: in red bold just for fun
authorColin Walters <walters@verbum.org>
Wed, 18 Sep 2013 20:34:14 +0000 (16:34 -0400)
committerColin Walters <walters@verbum.org>
Wed, 18 Sep 2013 20:34:14 +0000 (16:34 -0400)
It's easier to see.  Also drop old dead ot_main() function.

src/ostree/main.c
src/ostree/ot-main.c
src/ostree/ot-main.h

index f23e82601881ee7371db449c5e3c20946605f739..3e164f9ea7bce52e09d5b25b9092cd877a4d87ad 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <unistd.h>
 #include <locale.h>
 
 #include "ot-main.h"
@@ -75,7 +76,15 @@ main (int    argc,
 
   if (error != NULL)
     {
-      g_message ("%s", error->message);
+      int is_tty = isatty (1);
+      const char *prefix = "";
+      const char *suffix = "";
+      if (is_tty)
+        {
+          prefix = "\x1b[31m\x1b[1m"; /* red, bold */
+          suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */
+        }
+      g_printerr ("%serror: %s%s\n", prefix, suffix, error->message);
       g_error_free (error);
     }
 
index 1138f861093e7168a9f750655f48867c2dc5e9df..35302065690eb7ae80c8269ea19007bb537a3b84 100644 (file)
@@ -262,25 +262,3 @@ ostree_run (int    argc,
     }
   return 0;
 }
-
-int
-ostree_main (int    argc,
-             char **argv,
-             OstreeCommand *commands)
-{
-  GError *error = NULL;
-  int ret;
-
-  ret = ostree_run (argc, argv, commands, &error);
-
-  if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
-    ostree_usage (argv, commands, TRUE);
-
-  if (error)
-    {
-      g_message ("%s", error->message);
-      g_error_free (error);
-    }
-
-  return ret;
-}
index f13718666f665f1c239365d69c98deb7dd2c4c9b..49e310e863942f6d237690bb52f49c464dac4400 100644 (file)
@@ -36,8 +36,6 @@ typedef struct {
   int flags; /* OstreeBuiltinFlags */
 } OstreeCommand;
 
-int ostree_main (int    argc, char **argv, OstreeCommand  *commands);
-
 int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error);
 
 int ostree_usage (char **argv, OstreeCommand *commands, gboolean is_error);